﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using ChoDiaOc_HK_WPF.Models;

namespace ChoDiaOc_HK_WPF.Views.LapBaoBieu
{
    class TKDoanhThu
    {
        private string m_MaPhieuDangKy;

        public string MaPhieuDangKy
        {
            get { return m_MaPhieuDangKy; }
            set { m_MaPhieuDangKy = value; }
        }
        private string m_NgayDangKy;

        public string NgayDangKy
        {
            get { return m_NgayDangKy; }
            set { m_NgayDangKy = value; }
        }
        private string m_SoTien;

        public string SoTien
        {
            get { return m_SoTien; }
            set { m_SoTien = value; }
        }

        public static List<TKDoanhThu> getListDoanhThu(List<PHIEUDANGKY> listOld, int thang, int nam, ref float tongDT)
        {
            List<TKDoanhThu> listNew = new List<TKDoanhThu>();
            try
            {
                foreach (PHIEUDANGKY d in listOld)
                {
                    DBEntities entities = new DBEntities();
                    TKDoanhThu temp = new TKDoanhThu();
                    temp.MaPhieuDangKy = d.MaPhieuDangKy;
                    temp.NgayDangKy = d.TuNgay.Date.ToShortDateString();
                    temp.SoTien = d.SoTien.ToString();
                    DateTime thangnam = entities.PHIEUDANGKies.Where(t3 => t3.MaDiaOc == d.MaDiaOc).SingleOrDefault().TuNgay;
                    if (thang == thangnam.Month && nam == thangnam.Year)
                    {
                        tongDT += float.Parse(temp.SoTien.ToString());
                        listNew.Add(temp);
                    }
                }
            }
            catch (Exception ex)
            {
            }
            return listNew;
        }
    }
}
